<%@page contentType="text/html; charset=utf-8" language="java" import="cn.ac.cintcm.synonymous.*"  errorPage="" %>
<%@page import="java.util.List,java.sql.*,net.sf.json.*,java.util.*" %>
<%

String query = request.getParameter("query");
String sourceData =  request.getParameter("sourceData");
String stateTem = request.getParameter("state");
Integer state = new Integer(stateTem);
  try {
    //JSONObject jsonObject = JSONObject.fromString(query);
    if(sourceData != null && !(sourceData=sourceData.trim()).equals("")){
      	JSONArray sou = JSONArray.fromObject(sourceData);
    	JSONArray category = null;
    	if (query != null&& !query.trim().equals(""))
    	{
    	  category = JSONArray.fromObject(query);
    	}
    	long ls = System.currentTimeMillis();
    	Connection conn = OracleDb.getConnection();
      NameFieldDao  sourceDao = new NameFieldDao(conn, NameFieldDao.SOURCE);
      NameRecordDao nameRecordDao = new NameRecordDao(conn,null,sourceDao);
 	  ResultTable resultTable =  nameRecordDao.getComparison(sou,category,state);
 		
  	 if(resultTable != null)
  	 {
  	  	JSONObject jsonObject= JSONObject.fromObject(resultTable);
  	  	out.println(jsonObject);
  	  }
    }
  } catch (Exception e) {
    // crash and burn
    e.printStackTrace();
    throw new Exception("Error parsing JSON request string");
  }
%>